package cn.group01.git.common;

import lombok.Data;

// 返回信息
@Data
public class ResponseResult {
    private String msg;
    private Integer code;
    private Object data;
    private Long count;

    // 成功有数据
    public static ResponseResult success(CodeMsg codeMsg,Object data,Long count){
        String msg1 = codeMsg.getMsg();
        Integer code1 = codeMsg.getCode();
        ResponseResult responseResult = new ResponseResult();
        responseResult.setMsg(msg1);
        responseResult.setCode(code1);
        responseResult.setData(data);
        responseResult.setCount(count);
        return responseResult;
    }
    // 成功没有数据
    public static ResponseResult success(CodeMsg codeMsg){
        String msg1 = codeMsg.getMsg();
        Integer code1 = codeMsg.getCode();
        ResponseResult responseResult = new ResponseResult();
        responseResult.setMsg(msg1);
        responseResult.setCode(code1);
        return responseResult;
    }
    // 失败
    public static ResponseResult fail(CodeMsg codeMsg){
        String msg1 = codeMsg.getMsg();
        Integer code1 = codeMsg.getCode();
        ResponseResult responseResult = new ResponseResult();
        responseResult.setMsg(msg1);
        responseResult.setCode(code1);
        return responseResult;
    }
}
